#include<stdio.h>
void snakematrix(int a[100][100], int n,int line,int column,int number,int index,int signal);
int main()
{
   int matrix[100][100];
   int n,index=0;
   scanf("%d",&n);
   int line=0,column=0,number=1,signal=1;
   snakematrix(matrix,n,line,column,number,index,signal);
   matrix[n-1][n-1]=n*n;
   for(int i=0;i<n;i++)
    for(int j=0;j<n;j++)
    {
        printf("%d",matrix[i][j]);
        if(j!=n-1) printf(" ");
        else printf("\n");
    }
    return 0;
}

void snakematrix(int a[100][100], int n,int line,int column,int number,int index,int signal)
{
     if(line!=n-1||column!=n-1)
    {
      a[line][column]=number;
      number++;
      if((column==0||column==n-1)&&signal==1) 
      {
          if(column==0&&line==n-1) 
          {
            column++;
            signal=0;
            index=index==0?1:0;
          }
          else
          {
          line++;
          index=index==0?1:0;
          signal=0;
          }
      }
      else if((line==0||line==n-1)&&signal==1) 
      {
          column++;
          index=index==0?1:0;
          signal=0;
      }
      else
      {
        if(index==0)
        {
            line++;
            column--;
        }
        else
        {
            column++;
            line--;
        }
        signal=1;
      }
      snakematrix(a,n,line,column,number,index,signal);
    }
}

